package com.mc2.docapp.disabilityassessmenttool.LowerLimb;



import io.realm.RealmObject;
import io.realm.annotations.PrimaryKey;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class Lower_Limb_MobStab_ExtraPoints extends RealmObject {
    @PrimaryKey
    public int id;
    private LLCustDataType extraPoints = new LLCustDataType();
    private LLCustDataType shorteningPoints = new LLCustDataType();
    private LLInnerCalculations inner_calculations = new LLInnerCalculations();

    /*public Lower_Limb_MobStab_ExtraPoints(int id, LLCustDataType extraPoints, LLCustDataType shorteningPoints, LLInnerCalculations inner_calculations) {
        this.id = id;
        this.extraPoints = extraPoints;
        this.shorteningPoints = shorteningPoints;
        this.inner_calculations = inner_calculations;
    }*/

    public Lower_Limb_MobStab_ExtraPoints strip(Lower_Limb_MobStab_ExtraPoints dt) {
        return new Lower_Limb_MobStab_ExtraPoints(dt.getId(), dt.getExtraPoints(), dt.getShorteningPoints(), dt.getInner_calculations());

    }

    public void calc(Lower_Limb_MobStab_ExtraPoints lower_limb_mobStab_extraPoints) {

        double pa = lower_limb_mobStab_extraPoints.getExtraPoints().getActual_left();
        lower_limb_mobStab_extraPoints.getExtraPoints().setPerc_loss_left(pa);

        double pb = lower_limb_mobStab_extraPoints.getShorteningPoints().getActual_left();
        lower_limb_mobStab_extraPoints.getShorteningPoints().setPerc_loss_left(pb);

        double sumLeft = pa + pb  ;
        if(sumLeft > 10d) {
            sumLeft = 10d;
        }

        //RIGHT CAL

        pa = lower_limb_mobStab_extraPoints.getExtraPoints().getActual_right();
        lower_limb_mobStab_extraPoints.getExtraPoints().setPerc_loss_right(pa);

        pb = lower_limb_mobStab_extraPoints.getShorteningPoints().getActual_right();
        lower_limb_mobStab_extraPoints.getShorteningPoints().setPerc_loss_right(pb);

        double sumRight = pa + pb  ;
        if(sumRight > 10d) {
            sumRight = 10d;
        }

        lower_limb_mobStab_extraPoints.setInner_calculations(new LLInnerCalculations(
                0,
                0,
                sumRight,
                sumLeft

        ));
    }

    /*private double perc(double a, double normal) {
        return ((normal - a) * 100d) / (normal + 0d);
    }*/

}
